Imports Microsoft.VisualBasic

<Serializable()> _
Public Class Reporting
    Implements IComparable  'IMPORTANT

    Private _reportId As Integer
    Private _reportData() As Byte
    Private _timestamp As DateTime
    Private _simId As Integer
    Private _simName As String

    Private _status As String


    Public Property SimulationID() As Integer
        Get
            Return _simId
        End Get
        Set(ByVal value As Integer)
            _simId = value
        End Set
    End Property

    Public Property ReportID() As Integer
        Get
            Return _reportId
        End Get
        Set(ByVal value As Integer)
            _reportId = value
        End Set
    End Property


    Public Property ReportData() As Byte()
        Get
            Return _reportData
        End Get
        Set(ByVal value As Byte())
            _reportData = value
        End Set
    End Property

    Public Property TimeStamp() As DateTime
        Get
            Return _timestamp
        End Get
        Set(ByVal value As DateTime)
            _timestamp = value
        End Set
    End Property

    Public Property ReportStatus() As String
        Get
            Return _status
        End Get
        Set(ByVal value As String)
            _status = value
        End Set
    End Property

    Public Property SimulationName() As String
        Get
            Return _simName
        End Get
        Set(ByVal value As String)
            _simName = value
        End Set
    End Property

    Public Function ReportName() As String

        Dim name As New StringBuilder

        name.Append("Simulation_")
        name.Append(SimulationID & "_")
        name.Append(ReportID & "_")
        name.Append(TimeStamp & "_")
        name.Append(".xls")

        name.Replace("/", "_")
        name.Replace(" ", "_")
        name.Replace(":", "_")

        Return name.ToString()
    End Function

    Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo

        'where the Sorting logic is run

        'Basically says: "if ME greater than the obj card then return 1, if equal return 0 and if less than, return -1"

        If Not TypeOf obj Is Reporting Then Throw New ArgumentException 'make sure obj is a card before continuing

        Dim temp As Reporting = CType(obj, Reporting)

        Dim ts As DateTime = temp.TimeStamp



        If Me._timestamp > ts Then
            Return 1
        Else
            Return -1
        End If

    End Function

End Class
